package com.eshop.userorder.dao;



import java.sql.Connection;
import java.sql.PreparedStatement;

import java.sql.SQLException;

import com.eshop.dao.Conn;

public class DelOrderDao {
	
	private Connection conn = null;
	private PreparedStatement sta = null;
	int i = 0;
	
	public int delOrder(Integer ordersId)
	{
		conn = Conn.getConn();
		String sql = "UPDATE eshop.orders SET orders_status  =  0  WHERE orders.orders_id = ?";
		try {
			
			sta = conn.prepareStatement(sql);
			sta.setObject(1, ordersId);
			 i = sta.executeUpdate();
			
			
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}finally{
			try {
		
				if(sta != null)
				{
					sta.close();
				}
				if(conn != null)
				{
					conn.close();
				}
	} catch (SQLException e) {
		e.printStackTrace();
		
	}
}
	
	return i;
		
	}
	
	public int removeOrder(Integer ordersId)
	{
		conn = Conn.getConn();
		String sql = "UPDATE eshop.orders SET exist_users  =  0  WHERE orders.orders_id = ?";
		try {
			
			sta = conn.prepareStatement(sql);
			sta.setObject(1, ordersId);
			 i = sta.executeUpdate();
			
			
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}finally{
			try {
		
				if(sta != null)
				{
					sta.close();
				}
				if(conn != null)
				{
					conn.close();
				}
	} catch (SQLException e) {
		e.printStackTrace();
		
	}
}
	
	return i;
		
	}

}